home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
333_01
/
awk1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-04-21
|
26KB
|
982 lines
/***************************************************************************/
/* */
/* awk1 -- Expression tree constructors and main program for gawk. */
/* */
/* Copyright (C) 1986 Free Software Foundation */
/* Written by Paul Rubin, August 1986 */
/* */
/***************************************************************************/
/* */
/* GAWK is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY. No author or distributor accepts responsibility to anyone */
/* for the consequences of using it or for whether it serves any */
/* particular purpose or works at all, unless he says so in writing. */
/* Refer to the GAWK General Public License for full details. */
/* */
/* Everyone is granted permission to copy, modify and redistribute GAWK, */
/* but only under the conditions described in the GAWK General Public */
/* License. A copy of this license is supposed to have been given to you */
/* along with GAWK so you can know your rights and responsibilities. It */
/* should be in a file named COPYING. Among other things, the copyright */
/* notice and this notice must be preserved on all copies. */
/* */
/* In other words, go ahead and share GAWK, but don't try to stop */
/* anyone else from sharing it farther. Help stamp out software hoarding! */
/* */
/***************************************************************************/
/* */
/* Extensive code restructuring and port to MSDOS and MS OS/2 by: */
/* */
/* Bob Withers */
/* 649 Meadowbrook St. */
/* Allen, Texas 75002 */
/* December 8, 1988 */
/* */
/* The current state of gAWK (at least this version) is a subset of the */
/* AWK langauge as released on Unix in 1985 and defined in the book "The */
/* AWK Programming Langauge" by Aho, Kernighan, and Weinberger (1988). */
/* Following are language elements which are not supported in this */
/* version: */
/* */
/* - Actions */
/* */
/* o User defined functions are not supported */
/* */
/* o The "return [expression]" statement is not supported */
/* */
/* o The "delete array[i]" statement is not supported */
/* + Support added for "delete" by BW 01/02/89 */
/* */
/* - Input/Output */
/* */
/* o The "close(expr)" statement is not supported */
/* + Support for close() added by BW 12/21/88 */
/* - close(exp) ==> close file represented by "exp" */
/* - close() ==> close all redirected files */
/* - returns 1 for success, 0 for file not found */
/* */
/* o The "system(cmd_line)" statement is not supported */
/* + Support for "system" added by BW 12/6/88 */
/* */
/* o Use of pipes is not supported */
/* */
/* o Output redirection to files is supported for print and printf */
/* but there is not support for input redirection via getline */
/* */
/* - Built-in Variables */
/* */
/* o The following built-in variables are not supported: */
/* */
/* ARGC -- Support added by BW 12/26/88 */
/* ARGV -- Support added by BW 12/26/88 */
/* FNR -- Support added by BW 12/01/88 */
/* RLENGTH -- Support added by BW 12/21/88 */
/* RSTART -- Support added by BW 12/21/88 */
/* SUBSEP -- Support added by BW 12/26/88 */
/* */
/* - Built-in String Functions */
/* */
/* o The following built-in string functions are not supported: */
/* */
/* gsub(r, s, t) -- Support added by BW 12/22/88 */
/* match(s, r) -- Support added by BW 12/21/88 */
/* sub(r, s, t) -- Support added by BW 12/22/88 */
/* */
/* - Built-in Arithmetic Functions */
/* */
/* o The following built-in arithmetic functions are not supported: */
/* */
/* atan2(y, x) -- Support added by BW 12/03/88 */
/* cos(x) -- Support added by BW 12/03/88 */
/* rand() -- Support added by BW 12/20/88 */
/* sin(x) -- Support added by BW 12/03/88 */
/* srand(x) -- Support added by BW 12/20/88 */
/* */
/* - Expression Operators */
/* */
/* o The match operator (~) and not match operator (!~) only work */
/* on hardcoded regular expressions. They do not work on regular */
/* expressions in a variable. */
/* + Support for matching regular expression stored in a variable */
/* added by BW 01/06/88. The variable is forced to a string and */
/* compiled as a regular expression. If it contains an invalid */
/* regular expression execution is terminated with error msg. */
/* */
/* o The exponentiation operator (^) is not supported */
/* + Support for ^ added by BW 12/12/88. */
/* */
/* o The conditional expression "exp1 ? exp2 : exp3" is not supported */
/* + This has been fixed by BW on 12/20/88 */
/* */
/* - Misc */
/* */
/* o Source lines to be continued MUST be terminated by a backslash. */
/* Unix AWK allows lines to be continued at a comma without a */
/* backslash, gAWK does not. */
/* + This was fixed by BW 12/13/88 */
/* */
/* o Unix AWK allows a simple print statement to either use parens */
/* or not. gAWK does not allow parens on simple print's. */
/* + This was fixed by BW 12/13/88 */
/* */
/* o gAWK only allowed a single level of subscripting on array names. */
/* This was changed to support multi-level subscripts in the */
/* manner described in "The AWK Programming Language" which converts */
/* multidimension subscripts to a single subscript separated by */
/* the value of special variable SUBSEP. */
/* */
/* o The %f and %e format specifiers for printf() did not work */
/* properly. This was fixed by BW. */
/* */
/* o Large number of assumptions that sizeof(int) == sizeof(char *) */
/* were corrected by BW. */
/* */
/* o The split() function did not work properly when multiple field */
/* separators appeared between fields. This was fixed by BW. */
/* */
/* o The FS variable was enhanced to support regular expressions */
/* rather than the single character field seperator. While this */
/* is not documented in "The AWK Programming Language" it is */
/* implemented in the latest AWK version on UNIX (called NAWK). */
/* The default value of FS was changed from " " to "[\t ]+". */
/* */
/* - gAWK extensions - BW 12/20/88 */
/* */
/* o upper function added to return the string value of its argument */
/* converted to all upper case: */
/* */
/* $1 = upper($1) */
/* */
/* o lower function added to return the string value of its argument */
/* converted to all lower case: */
/* */
/* $1 = lower($1) */
/* */
/* o reverse function added to return the string value of its */
/* argument reversed: */
/* */
/* $1 = reverse($1) */
/* */
/***************************************************************************/
#define DRIVER
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "awk.h"
#define VERSION "3.00"
STATIC char * NEAR PASCAL extract_module_name(char *argv0);